package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserReq;
import com.bwie.common.domain.response.JwtRes;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AuthApplication
 * @Description:
 * @Author: ZengFz
 * @Date: 2024/5/17 9:31:03
 */
@RestController
@RequestMapping("/user")
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    public Result<JwtRes> login(@RequestBody UserReq userReq){
        return authService.login(userReq);
    }

    @GetMapping("/info")
    public Result<User> info(){
        return Result.success(authService.info());
    }

    @PostMapping("/logout")
    public Result logout(){
        authService.logout();
        return Result.success();
    }

}
